package com.cch.examSystem.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cch.examSystem.entity.QuestionList;
import com.cch.examSystem.entity.ScoreList;

public class QuestionListServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		Date now = new Date();
		SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat time = new SimpleDateFormat("HH:mm");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();

		List questionList = new ArrayList();
		QuestionList question;
		String scaleName = "测试问卷";
		String questionStr = "测试问题";
		String userName = "测试用户";
		for (int i = 0; i < 15; i++) {
			question = new QuestionList(i, "反射", userName + i, questionStr + i,
					"A", i+1, 1, 1, datetime.format(now), "[{\"A\":\"sdfasd\"},{\"B\":\"fasdf\"},{\"C\":\"asdf\"},{\"D\":\"asdf\"}]");
			questionList.add(question);
		}
		for (int i = 15; i < 30; i++) {
			question = new QuestionList(i, "JDBC", userName + i, questionStr
					+ i, "BC", i, 2, 2, datetime.format(now), "[{\"A\":\"sdfasd\"},{\"B\":\"fasdf\"},{\"C\":\"asdf\"},{\"D\":\"asdf\"}]");
			questionList.add(question);
		}
		request.setAttribute("questionList", questionList);
		request.getRequestDispatcher("./manager/questionList.jsp").forward(
				request, response);
		out.flush();
		out.close();
	}
}
